﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Userscs 的摘要说明
/// </summary>

    public class Users:SQlHelper
    {
        private string _ps;
        private string _name;
        private string _id;
        private string _number;
        public string ps
        {
            get
            { 
                return _ps;
            }
            set
            { 
                _ps = value;
            }
        }
        public string name
        {
            get
            {
                return _name;
            }
            set
            { 
                _name = value;
            }
        }
        public string id
        {
            get 
            { 
                return _id; 
            }
            set
            { 
                _id = value;
            }
        }
        public string number
        {
            get
            {
                return _number;
            }
            set
            {
                _number = value;
            }
        }
        //添加一个管理员
        public int Addoneuser(Users tmp)
        {
            string sql = "insert into Admin_users(Admin_ID,Admin_Password) values('" + tmp.name + "','" + tmp.ps + "')";
            int result = tmp.ExeNonquery(sql);
            return result;
        }
        //管理登录
        public int denglu(Users tmp)
        {
            string sql = "select count(*) from Admin_users where Admin_ID='" + tmp.id + "'and Admin_Password='" + tmp.ps + "'";
            int result = tmp.ExeScalar(sql);
            return result;
        }
        //删除车主信息
        public int DeleteCaruser(Users tmp)
        {
            string sql = "delete from Car_users where CAR_NUMBER='" + tmp.number + "'";
            int result = tmp.ExeNonquery(sql);
            return result;
        }
        //删除消费者信息
        public int DeleteTourist(Users tmp)
        {
            string sql = "delete from Tourist_users where Tourist_ID='" + tmp.id + "'";
            int result = tmp.ExeNonquery(sql);
            return result;
        }
        //查看车主信息
        public SqlDataReader Carusers(Users tmp)
        {
            string sql = "select * from Car_users,where CAR_NUMBER='" + tmp.number+ "'";
            SqlDataReader rd = tmp.Exereader(sql);
            return rd;
        }
        //查看消费者信息
        public SqlDataReader Tourist(Users tmp)
        {
            string sql = "select * from Tourist_users,where Tourist_ID='" + tmp.id + "'";
            SqlDataReader rd = tmp.Exereader(sql);
            return rd;
        }
    }
